#pragma once
#include "ianimation.h"
#include "abstract_picture.h"

#include <vector>

namespace Commands
{
    namespace Core
    {
        class Inspector;
    }

    class AbstractAnimation : public AbstractPicture, public IAnimation
    {
    public:
        ~AbstractAnimation();

        virtual void SetCurrentFrame(const size_t frame);
    
        virtual int GetCurrentFrame(void) const;
    
        virtual int GetFramesCount(void) const;
    
        virtual void NextFrame(void);

        /** \anchor SetSequence
        */
        void SetSequence(const char* const sequence);

        /** \anchor DropSequence
        */
        void DropSequence(void);

        void Accept(const Core::Inspector& inspector);

    protected:
        AbstractAnimation();

        size_t currentFrameIdx;
        size_t loadedFrames;
        size_t sequencedFrameIdx;
        std::vector<size_t> sequencedFrames;

    private:
        void coma_split(char* str);
        void dash_split(char* str);
        void make_range(const size_t first_number, const size_t last_number);
        size_t make_number(char* const str) const;
        bool is_valid(char* const str) const;
    };
}//namespace
